import javax.swing.table.*;
import javax.swing.*;
import java.awt.*;

public class ManageBFHserver extends JApplet{
    public static void main(String[] args) {
        ManageBFHserver operationalObj = new ManageBFHserver();
        operationalObj.makeGUI();
    }
    
    void makeGUI() {
        JTabbedPane jtp = new JTabbedPane();
        JMenuBar menuBar = new JMenuBar();
        JMenu menu = new JMenu("Menu");
        JFrame frame = new JFrame("<<:: BFH administrēšanas instruments ::>>");
        
        // Menu item list
        menuBar.add(menu);
        JMenuItem newServerItem = new JMenuItem("Cits serveris");
        JMenuItem settingsItem = new JMenuItem("Iestatījumi");
        JMenuItem exitAppItem = new JMenuItem("Izslēgt!");
        menu.add(newServerItem);
        menu.add(settingsItem);
        menu.addSeparator();
        menu.add(exitAppItem);
        
        // GUI components
        JLabel serverLable = new JLabel("###Serveris###");
        frame.add(serverLable);
        frame.setLocation(20, 20);
        jtp.addTab("Karalauks", new BattlefieldPanel());
//        jtp.setPreferredSize(new Dimension(560, 585));
        frame.add(jtp);
        jtp.addTab("Iestatījumi", new SettingsPanel());
        frame.add(jtp);
        jtp.addTab("Melnais saraksts", new BlackListPanel());
        frame.add(jtp);
        jtp.addTab("Vēsture", new HistoryPanel());
        frame.add(jtp);
        jtp.addTab("Par..", new AboutPanel());
        frame.add(jtp);
        frame.setSize(580, 660);
        frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
        frame.setJMenuBar(menuBar);
    }
}

// Team members and all related info
class BattlefieldPanel extends JPanel{
    public BattlefieldPanel() {
        JPanel panel = new JPanel();
        String[] tags = {
            "ID", "Hero", "Punkti", "K", "D", "Klase", "Līmenis",
            "Ping", "Dīkā", "Wārnas"};
        
        String dataValues[][] = {{ "1", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "2", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "5", "35", "0", "0"},
        { "3", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "4", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "12", "35", "0", "0"},
        { "5", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "6", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "23", "35", "0", "0"},
        { "7", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "8", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "9", "SatisClamCursusSatisClamSatis", "4500", "15", "0", "Commando",
                            "7", "35", "0", "0"},
        { "10", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "11", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "12", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "13", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "14", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "15", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"},
        { "16", "SatisClamCursus", "4500", "15", "0", "Commando",
                            "30", "35", "0", "0"}};
        
        panel.setPreferredSize(new Dimension(559, 590));
        
        // Score information
        JLabel royalScore = new JLabel("royal");
        JLabel nationalScore = new JLabel("national");
        panel.add(royalScore);
        panel.add(nationalScore);
        
        // List of players with related info
        JTable tabula = new JTable(new DefaultTableModel(dataValues, tags));
        tabula.setPreferredSize(new Dimension(560, 255));
        tabula.setShowGrid(false);
        DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
        centerRenderer.setHorizontalAlignment(JLabel.CENTER);
        tabula.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);
        tabula.getColumnModel().getColumn(2).setCellRenderer(centerRenderer);
        tabula.getColumnModel().getColumn(3).setCellRenderer(centerRenderer);
        tabula.getColumnModel().getColumn(4).setCellRenderer(centerRenderer);
        tabula.getColumnModel().getColumn(6).setCellRenderer(centerRenderer);
        tabula.getColumnModel().getColumn(7).setCellRenderer(centerRenderer);
        tabula.getColumnModel().getColumn(8).setCellRenderer(centerRenderer);
        tabula.getColumnModel().getColumn(9).setCellRenderer(centerRenderer);
        tabula.getColumnModel().getColumn(0).setPreferredWidth(20);
        tabula.getColumnModel().getColumn(1).setPreferredWidth(160);
        tabula.getColumnModel().getColumn(2).setPreferredWidth(40);
        tabula.getColumnModel().getColumn(3).setPreferredWidth(20);
        tabula.getColumnModel().getColumn(4).setPreferredWidth(30);
        tabula.getColumnModel().getColumn(5).setPreferredWidth(80);
        tabula.getColumnModel().getColumn(7).setPreferredWidth(30);
        tabula.getColumnModel().getColumn(8).setPreferredWidth(30);
        tabula.getColumnModel().getColumn(9).setPreferredWidth(30);
        panel.add(tabula);
        
        // Chat text edit panel and send button
        JTextField chatField = new JTextField();
        chatField.setPreferredSize(new Dimension(480, 20));
        panel.add(chatField);
        JButton poga = new JButton("Kliegt!");
        panel.add(poga);
        
        // Chat and message output window
        JTextArea chatOutput = new JTextArea();
        chatOutput.setEditable(false);
        chatOutput.setPreferredSize(new Dimension(560, 250));
        chatOutput.setText("Some bullshit...");
        panel.add(chatOutput);
        add(panel);
    }
}

// Panel which contains information about server and chat acitivity
class HistoryPanel extends JPanel {
    public HistoryPanel() {
        JPanel panel = new JPanel();
        panel.setPreferredSize(new Dimension(560, 590));
        JTextArea textVieta = new JTextArea("This string should be"
                + " overrided by an object..");
        textVieta.setLocation(0, 0);
//        textVieta.setSize(560, 640);
        textVieta.setVisible(true);
        textVieta.setText("Some text bullshit...");
        textVieta.setEditable(false);
        panel.add(textVieta);
        add(panel);
    }
}

// Black list - list of players, banned for life
class BlackListPanel extends JPanel {
    public BlackListPanel() {
        JPanel panel = new JPanel();
        JScrollPane scrollPane = new JScrollPane();
        String[] tags = {
            "Varonis", "BFH ID", "Iemesls", "Kad?"};
        
        String dataValues[][] = {{ "SatisClamCursus", "232233232", "Get lost, cheater!",
                            "16.11.2013. 14:28:20"},
            { "SatisClamCursus", "232233232", "Get lost, cheater!",
                            "16.11.2013. 14:28:20"},
            { "SatisClamCursus", "232233232", "Get lost, cheater!",
                            "16.11.2013. 14:28:20"},
            { "SatisClamCursus", "232233232", "Get lost, cheater!",
                            "16.11.2013. 14:28:20"},
            { "SatisClamCursus", "232233232", "Get lost, cheater!",
                            "16.11.2013. 14:28:20"},
            { "SatisClamCursus", "232233232", "Get lost, cheater!",
                            "16.11.2013. 14:28:20"},
            { "SatisClamCursus", "232233232", "Get lost, cheater!",
                            "16.11.2013. 14:28:20"},
            { "SatisClamCursus", "232233232", "Get lost, cheater!",
                            "16.11.2013. 14:28:20"}};
        
        panel.setPreferredSize(new Dimension(559, 590));
        // List of players with related info
        JTable tabula = new JTable(new DefaultTableModel(dataValues, tags));
        tabula.setPreferredSize(new Dimension(560, 255));
        panel.add(tabula);
        scrollPane.add(panel);
        add(panel);
    }
}

class SettingsPanel extends JPanel {
    public SettingsPanel() {
        JTextField loginField = new JTextField();
        JPasswordField pswField = new JPasswordField();
        loginField.setPreferredSize(new Dimension(80, 20));
        loginField.setLocation(20, 20);
        add(loginField);
        pswField.setPreferredSize(new Dimension(80, 20));
        add(pswField);
    }
}

class AboutPanel extends JPanel {
    public AboutPanel() {
        String s = "Programmu izveidoja SatisClam (BFH spēles varonis).";
        JLabel label = new JLabel();
        label.setText(s);
        add(label);
    }
}